<template>
  <view class="container font-B">
    <view class="container-item c-b-fff jh-space-between jh-align-center" style="height: 170rpx;">
      <view class="font-34 c-000">头像</view>
      <view class="jh-align-center">
        <image style="width: 150rpx;height: 150rpx;display: block;" :src="info.head_pic  ? info.head_pic : ossDomain + '/wx.png'"></image>
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center" @tap="$navigateTo('/pages/own/edit')">
      <view class="font-34 c-000">名字</view>
      <view class="jh-align-center">
        <view class="font-34 c-999">{{info.name || ''}}</view>
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center">
      <view class="font-34 c-000">卡罗琳号</view>
      <view class="jh-align-center">
        <view class="font-34 c-999">{{info.kaluolin_username || ''}}</view>
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center">
      <view class="font-34 c-000">职称</view>
      <view class="jh-align-center">
        <view class="font-34 c-999">{{info.professional_title || ''}}</view>
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center">
      <view class="font-34 c-000">医院</view>
      <view class="jh-align-center">
        <view class="font-34 c-999">{{info.hospital || ''}}</view>
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center">
      <view class="font-34 c-000">地区</view>
      <view class="jh-align-center">
        <view class="font-34 c-999">中山</view>
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center" @tap="$navigateTo('/pages/own/more')">
      <view class="font-34 c-000">更多</view>
      <view class="jh-align-center">
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center" @tap="checkVersion">
      <view class="font-34 c-000">版本</view>
      <view class="jh-align-center">
        <view class="font-34 c-999">{{version}}</view>
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
    <view class="container-item c-b-fff jh-space-between jh-align-center" @tap="logout()">
      <view class="font-34 c-000">退出登录</view>
      <view class="jh-align-center">
        <image class="margin-l30" style="width: 6px;height: 22rpx;display: block;" :src="ossDomain + '/rightArrow2.png'"></image>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    mapState
  } from 'vuex'
  import {checkVersion} from '@/utils/index.js'
  export default {
    data() {
      return {
        ossDomain: uni.ossDomain,
        info: {},
        version: '1.0.0',
      }
    },
    computed: {
      ...mapState({
        userInfo: state => state.user.userInfo
      })
    },
    onShow() {
      this.getInfo()
      this.info = this.userInfo.user || {}
      // #ifdef APP-PLUS
      plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
        this.version = wgtinfo.version
      })
      //#endif
    },
    methods: {
      getInfo () {
        this.$http.getInfo().then(res => {
          this.info = res.data[0]
          this.userInfo.user = Object.assign(this.userInfo.user,this.info)
          this.$store.commit('setUserInfo', this.userInfo);
          this.info = this.userInfo.user
        })
      },
      open(url) {
        uni.navigateTo({
          url: url
        });
      },
      checkVersion () {
        this.$http.appUpdated().then(res => {
          let info = res.data
          console.log(info);
          if (checkVersion(this.version,info.version)) {
            uni.showModal({
              title: '提示',
              content: '发现新版本: ' + info.version,
              success: (e) => {
                if (e.confirm) {
                  uni.setStorageSync('update',info)
                  this.$navigateTo('/pages/system/update/index')
                }
              }
            })
          }
        })
      },
      logout() {
        this.$store.dispatch('resetStore')
        uni.$app.logout()
        uni.hideLoading()
        uni.reLaunch({
          url: '/pages/login/main'
        })
      }
    }
  }
</script>

<style lang='scss' scoped>
  .container {
    background-color: #F8F8F8;
    height: 100vh;
    &-item{
      height: 110rpx;
      padding: 0 32rpx;
      border-bottom: 1px solid #ddd;
    }
  }
</style>
